using System;
using System.Reflection;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using Flowgraph;
using Flowgraph.Attributes;

namespace Flowgraph.Editor
{
    [ExposeType(1)]
    public class Core : Game
    {
        //---------------------------------------------------------------------------------------
        private static GraphicsDeviceManager m_Graphics;
        private SpriteBatch m_SpriteBatch;

        //---------------------------------------------------------------------------------------
        private Matrix m_WorldMatrix;
        private Matrix m_ViewMatrix;

        //---------------------------------------------------------------------------------------
        private Engine m_FlowgraphEngine;

        //---------------------------------------------------------------------------------------
        public static GraphicsDeviceManager GraphicsManager { get { return m_Graphics; } }

        //---------------------------------------------------------------------------------------
        public Core()
        {
            m_Graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        //---------------------------------------------------------------------------------------
        protected override void Initialize()
        {
            base.Initialize();
            m_WorldMatrix = Matrix.CreateTranslation(Vector3.Zero);
            m_ViewMatrix = Matrix.CreateOrthographic(100f, 100f, 0.1f, 100.0f);

            m_FlowgraphEngine = new Engine();
            m_FlowgraphEngine.ScanAssembly(Assembly.GetExecutingAssembly().Location);
        }

        //---------------------------------------------------------------------------------------
        [ExposeMethod(1)]
        protected override void LoadContent()
        {
            m_SpriteBatch = new SpriteBatch(GraphicsDevice);
        }

        //---------------------------------------------------------------------------------------
        protected override void UnloadContent()
        {
        }

        //---------------------------------------------------------------------------------------
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        //---------------------------------------------------------------------------------------
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);
        }
    }
}
